﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NetHackLib;
using System.Threading;

namespace NetHack___Big_Assignment
{
    class Program
    {
        //const ConsoleColor HERO_COLOR = ConsoleColor.DarkBlue;  
        //const ConsoleColor BACKGROUND_COLOR = ConsoleColor.Green;  
        //public static Coordinate Character { get; set; } //Will represent our hero that's moving around :P  
        
        //static void MoveHero(int x, int y)  
        //{
        //Coordinate newHero = new Coordinate()  
        //{
        //    X = Character.X + x,
        //    Y = Character.Y + y
        //};  

        //    if (CanMove(newHero))  
        //    {  
        //    RemoveHero();  
        //    Console.BackgroundColor = HERO_COLOR;
        //    Console.SetCursorPosition(newHero.X, newHero.Y);
        //    Console.Write(" ");
        //    Character = newHero;
        //    }  
        //}  

        //static void RemoveHero()  
        //{  
        //Console.BackgroundColor = BACKGROUND_COLOR;  
        //Console.SetCursorPosition(Character.X, Character.Y);  
        //Console.Write(" ");  
        //}  

        //static bool CanMove(Coordinate c)  
        //{  
        //if (c.X < 0 || c.X >= Console.WindowWidth)  
        //return false;  

        //if (c.Y < 0 || c.Y >= Console.WindowHeight)  
        //return false;  
        //return true;  
        //}  

        //static void SetBackgroundColor()  
        //{  
        //Console.BackgroundColor = BACKGROUND_COLOR;  
        //Console.Clear(); //Important!  
        //}

        //static void InitGame()
        //{
        //    SetBackgroundColor();
        //    Character = new Coordinate()
        //    {
        //        X = 0,
        //        Y = 0
        //    };
        //    MoveHero(0, 0);
        //}
        //    class Coordinate  
        //{  
        // public int X { get; set; } //Left  
        // public int Y { get; set; } //Top  
        //} 

        static void Main(string[] args)
        {
            //InitGame();

            Console.WriteLine("===========================");
            Console.WriteLine("Welcome To the NetHack Game");
            Console.WriteLine("===========================");
            Console.WriteLine();

            //Prompt For Hero Name
            Console.WriteLine("Please input name:");
            string cname = Console.ReadLine();
            Console.Clear();

            //Prompt For The Hero Race
            Console.WriteLine("Please choose a race :\n 1. Dwarf \n 2. Human \n 3. Elf \n 4. Argonian \n 5. Angel \n 6. Demon \n 7. Insectoid \n 8. Orc \n 9. Undead \n");
            Race race = (Race)int.Parse(Console.ReadLine());
            Console.Clear();

            //Prompt for A Hero Class
            Console.WriteLine("Please choose a class :\n 1. Fighter \n 2. Cleric \n 3. Rogue \n 4. Wizzard \n 5. BugLord \n 6. Dementor \n 7. AntiMage \n 8. Thief \n 9. Warrior \n 10. Seeker");
            Class cclass = (Class)int.Parse(Console.ReadLine());
            Console.Clear();

            //Prompt for A Hero Class
            Console.WriteLine("You Are a Descendant of a :\n 1. City Guard \n 2. Magician \n 3. Dancing Swordsman \n 4. Librarian \n 5. Teacher \n 6. Alchemist");
            Special sspecial = (Special)int.Parse(Console.ReadLine());
            Console.Clear();

            //Assign the Hero Player Instance A Name, Race and Class to that which was prompted for
            Character Player = new Character(cname, race, cclass, sspecial);

            //Display The Method Player Which Shows its Stats
            Console.WriteLine("Character Details:");
            Console.WriteLine();
            Console.WriteLine(Player);

            Console.WriteLine();
            Console.WriteLine("Continue 1. Yes Or 2. No");
            int proceed = int.Parse(Console.ReadLine());
            Console.Clear();

            if (proceed == 1)
            {
                while (Player.GetHealth() >= 1)
                {
                    switch (proceed)
                    {
                        case 1:
                            ConsoleKeyInfo mykey = Console.ReadKey();
                            Console.Clear();
                            switch (mykey.Key)
                            {
                                case ConsoleKey.UpArrow:
                                    Player.BasicCharInfo();
                                    Console.WriteLine();
                                    Player.generateMap();
                                    Console.WriteLine();
                                    Console.WriteLine("Moving up");
                                    Console.WriteLine();
                                    //MoveHero(0, -1);
                                    break;
                                case ConsoleKey.RightArrow:
                                    Player.BasicCharInfo();
                                    Console.WriteLine();
                                    Player.generateMap();
                                    Console.WriteLine();
                                    Console.WriteLine("Moving Right");
                                    Console.WriteLine();
                                    //MoveHero(1, 0);
                                    break;
                                case ConsoleKey.LeftArrow:
                                    Player.BasicCharInfo();
                                    Console.WriteLine();
                                    Player.generateMap();
                                    Console.WriteLine();
                                    Console.WriteLine("Moving Left");
                                    Console.WriteLine();
                                    //MoveHero(-1, 0);
                                    break;
                                case ConsoleKey.DownArrow:
                                    Player.BasicCharInfo();
                                    Console.WriteLine();
                                    Player.generateMap();
                                    Console.WriteLine();
                                    Console.WriteLine("Moving Down");
                                    Console.WriteLine();
                                    //MoveHero(0, 1);
                                    break;
                                //case ConsoleKey.I:
                                //    Console.WriteLine("Welcome to Your Inventory");
                                //    //Console.WriteLine("Current Weapon : {}", Player.);
                                default:
                                    if ((mykey.Key != ConsoleKey.UpArrow) || (mykey.Key != ConsoleKey.DownArrow) || (mykey.Key != ConsoleKey.LeftArrow) || (mykey.Key != ConsoleKey.RightArrow))
                                    {
                                        Console.WriteLine("Invalid Choice !!! ");
                                        //Hero.MoveHero(0, 0);
                                        Console.ReadKey();
                                    }
                                    break;
                            }
                        break;
                    }
                }
            }
            if (proceed == 2)
            {
                Console.WriteLine("Press Any Key To Exit");
                Console.ReadKey();
            }
        }
    }
}
